package com.qingchunlin.springprinciple.config;

import com.qingchunlin.springprinciple.entity.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.web.context.annotation.ApplicationScope;
import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.context.annotation.SessionScope;

@Configuration
public class BeanConfig {
    @Bean
    public User user1() {
        return new User(1, "张三");
    }

    @Bean
    public User user2() {
        return new User(2, "李四");
    }

    @Bean
//    @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
    @Scope("singleton")
    public User singleUser() {
        return new User();
    }

    @Bean
//    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    @Scope("prototype")
    public User prototypeUser() {
        return new User();
    }

    @Bean
    @RequestScope
    public User requestUser() {
        return new User();
    }

    @Bean
    @SessionScope
    public User sessionUser() {
        return new User();
    }

    @Bean
    @ApplicationScope
    public User applicationUser() {
       return new User();
    }
}
